package com.ruoyi.scheduleTask;

import lombok.extern.slf4j.Slf4j;
import org.quartz.JobKey;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;

@Slf4j
public class CommonUtil {

    /**
     * 暂停一个job,暂停后，任务若未执行完，会执行完毕为止。
     */
    public static void removeJob(Scheduler scheduler, String jobName, String jobGroupName) {
        try {
            scheduler.deleteJob(new JobKey(jobName, jobGroupName));
            log.info(String.format("定时任务%s暂停成功！", jobName));
        } catch (SchedulerException e) {
            log.error(String.format("定时任务%s暂停异常！", jobName), e);
        }
    }
}
